package com.kstech.mp3604.adapter

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView


/**
 * author: blankii
 * created on: 2025/3/28 14:32
 * description:
 */
/**
 * author: lenovo
 * created on: 2023/12/19 13:44
 * description: 给gridLayoutManger 分隔间隔
 */
class GridSpaceItemDecoration(//行间距
    private val mRowSpacing: Int, // 列间距
    private var mColumnSpacing: Int
) : RecyclerView.ItemDecoration() {
    private val mSpanCount = 0 //横条目数量

    /**
     * //     * @param spanCount     列数
     * @param rowSpacing    行间距
     * @param columnSpacing 列间距
     */
    init {
//        this.mSpanCount = spanCount;
        mColumnSpacing = mColumnSpacing
    }

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
//        int position = parent.getChildAdapterPosition(view); // 获取view 在adapter中的位置。
//        int column = position % mSpanCount; // view 所在的列
        outRect.left = mColumnSpacing
        outRect.right = mColumnSpacing
        outRect.top = mRowSpacing // item top
//        outRect.bottom = mRowSpacing
    }
}

